//
//  NSString+hf.m
//  HFObjComment
//
//  Created by 韩艳锋 on 2019/7/29.
//

#import "NSString+hf.h"

@implementation NSString (hf)
-(CGSize)sizeWithStringShowSize:(CGSize)size showFont:(UIFont*)font{
    //固定宽获取高度size：CGSizeMake(100, MAXFLOAT)
    //固定高获取宽度size：CGSizeMake(MAXFLOAT,100)
    CGSize stringSize = [self boundingRectWithSize:size options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:font} context:nil].size;
    return stringSize;
}

- (CGFloat)getWidthWithFont:(UIFont*)font {
    return [self sizeWithStringShowSize:CGSizeMake(MAXFLOAT,MAXFLOAT) showFont:font].width;
}
@end
